package com.talkology.pilot.student.service.impl;

import com.talkology.pilot.database.dao.UserMapper;
import com.talkology.pilot.database.model.User;
import com.talkology.pilot.student.service.IStudentUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class StudentUserServiceImpl implements IStudentUserService {

    @Autowired
    private UserMapper mapper;

    @Override
    public List<User> getAllByFilter(User name) {
        return this.mapper.selectByFilter(name);
    }

    @Override
    public User getInfo(Long index) {
        return this.mapper.selectByPrimaryKey(index);
    }

    @Override
    @Transactional
    public void add(User record) {
        this.mapper.insert(record);
    }

    @Override
    @Transactional
    public void edit(User record) {
        this.mapper.updateByPrimaryKey(record);
    }

    @Override
    @Transactional
    public void delete(Long record) {
        this.mapper.deleteByPrimaryKey(record);
    }
}
